<?php
namespace Admin\Controller;
use Admin\Controller;
/**
 * 分类管理
 */
class IndexController extends BaseController
{
    /**
     * 分类列表
     * @return [type] [description]
     */
    public function index(){//修改数据
        //设置字符集
        header("Content-Type:text/html; charset=utf-8");

        $list = I('list');//1 jour 2 list 3 ctivity 4 server
        $where['id'] = I('register');// id

        if($list=='jour'){
            $type =1;
            $model = M('journalism');
        }

        if($list=='list'){
            $type =2;
            $model = M('list_image');
        }
        if($list=='ctivity'){
            $model = M('new_activity');
        }
        if($list=='server'){
            $type =4;
            $model = M('new_server');
        } 

        if($list=='rotation'){
            $type =6;
            $model = M('rotation');
        }
        $up  = $model->where($where)->find();
        if($list=='ctivity'){
            if($up['status']==2){
                 $type =3;//最新活动
            }else{
                $type =5;//攻略
            }
        }
        $this->assign('up',$up);
        $this->assign('type',$type);
        $this->display();   
    }

    public function modify(){//修改
        $list = I('list');//1 jour 2 list 3 ctivity 4 server
        $where['id'] = I('listRows');//id
        if($list=='jour'){
            $save['status'] = I('num');
            $save['title'] = I('title');
            $save['content'] = I('editor');
            $model = M('journalism');
        }
        if($list=='ctivity'){
            $save['img'] = I('img');
            $save['status'] = I('status');
            $save['title'] = I('title');
            $save['content'] = I('content');
            $model = M('new_activity');
        }
        if($list=='server'){
            $save['newname'] = I('newname');
            $model = M('new_server');
        }
        
        $up  = $model->where($where)->save($save);
        if($up){
            $this->success("修改成功！",U('Ent/index'));exit();
        }
            $this->success("修改失败！请重新修改！", U('Ent/index'));exit();
    }

   
}
